package container.set;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

public class T02_SynchronizedSet {
    public static void main(String[] args) {
        Set<String> set = new HashSet<>();
        Set<String> setSync = Collections.synchronizedSet(set);

        for (int i = 0; i < 30; i++) {
            new Thread(() -> {
                setSync.add(UUID.randomUUID().toString().substring(0, 8));
                // setSync.forEach(System.out::println);
                System.out.println(setSync);
            }, String.valueOf(i)).start();
        }
    }
}